//
//  UIButton+help.m
//  Tuotuo
//
//  Created by Apple on 14-1-14.
//  Copyright (c) 2014年 Gaialine. All rights reserved.
//

#import "UIButton+Help.h"

@implementation UIButton (Help)



- (void)        buttonWithNormalTitleColor:(UIColor *)normalColor
                     highlightedTitleColor:(UIColor *)highlightedColor
{
    normalColor = normalColor ? normalColor : [UIColor whiteColor];
    highlightedColor = highlightedColor ? highlightedColor : [UIColor whiteColor];
    
    [self setTitleColor:normalColor forState:UIControlStateNormal];
    [self setTitleColor:highlightedColor forState:UIControlStateHighlighted];
}

+ (UIButton *)buttonWithTitle:(NSString *)title
                   titleColor:(UIColor *)titleColor
              backgroundColor:(UIColor *)backgroundColor
                       target:(id)target
                       action:(SEL)action 
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitle:title forState:UIControlStateHighlighted];
    
    if (titleColor) {
        [button setTitleColor:titleColor forState:UIControlStateNormal];
        [button setTitleColor:titleColor forState:UIControlStateHighlighted];
    }
    
    if (backgroundColor) {
        [button setBackgroundColor:backgroundColor];
    }
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return button;
}
+ (UIButton *)buttonWithImage:(UIImage *)image target:(id)target
                       action:(SEL)action frame:(CGRect)frame
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:frame];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button setBackgroundImage:image forState:UIControlStateHighlighted];
    [button setBackgroundImage:image forState:UIControlStateSelected];

    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return button;
}
+ (UIButton *)buttonWithtarget:(id)target
                       action:(SEL)action frame:(CGRect)frame
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:frame];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return button;
}


+(UIButton *)buttonWithTitle:(NSString *)title target:(id)target action:(SEL)action andFrmae:(CGRect)frmae;
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [btn setFrame:frmae];
    return btn;
}
+ (UIButton*)buttonWithImage:(UIImage *)image slectedImage:(UIImage*)seletedImage target:(id)target action:(SEL)action frame:(CGRect)frame
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:frame];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button setBackgroundImage:seletedImage forState:UIControlStateHighlighted];
    [button setBackgroundImage:seletedImage forState:UIControlStateSelected];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return button;
}

@end
